<!doctype html>
<html lang="zh"><head>
<title>git-Git常用操作整理 - 糖羽仙</title>
<meta charset="UTF-8">
<meta name="keywords" content="blog ACG JavaScript VUE IT">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">

<link rel="shortcut icon" href="/images/head/head.jpg" type="image/jpeg" />
<meta name="description" content="Git常用操作整理…">
<meta property="og:type" content="article">
<meta property="og:title" content="git-Git常用操作整理">
<meta property="og:url" content="https://www.tangyuxian.com/2021/08/13/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/git/git-Git%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C%E6%95%B4%E7%90%86/index.html">
<meta property="og:site_name" content="糖羽仙">
<meta property="og:description" content="Git常用操作整理…">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813100147449.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813100121447.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813102546895.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813104533648.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813104738794.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813105228259.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813105329430.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813115345755.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813115526464.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813132434260.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813132632230.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813132746452.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813133729555.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813134333892.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813134601212.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813134706819.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813135718369.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813140211171.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813140902822.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813141313715.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813141558893.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813145829941.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813150225555.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813150419586.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813150550178.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813151449597.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813151548854.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813151658048.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155225050.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155241666.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155250923.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155306599.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155316585.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155333578.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155514556.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155822581.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155923526.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813160042246.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813160058861.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813160112683.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813160130746.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813160215210.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813161758028.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813162919105.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813163337230.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813163622576.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813163821444.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813165148007.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813165633739.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813170306723.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813170314683.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813170329076.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813170336371.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813170345098.png">
<meta property="article:published_time" content="2021-08-13T01:48:56.000Z">
<meta property="article:modified_time" content="2022-08-20T10:06:06.035Z">
<meta property="article:author" content="tangyuxian">
<meta property="article:tag" content="git">
<meta property="article:tag" content="转载">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813100147449.png">

<link rel="stylesheet" href="/lib/fancybox/fancybox.css">
<link rel="stylesheet" href="/lib/mdui_043tiny/mdui.css">


<link rel="stylesheet" href="/lib/iconfont/iconfont.css?v=1763992124105">

    <link rel="stylesheet" href="//at.alicdn.com/t/font_2421060_8z08qcz5sq3.css">

<link rel="stylesheet" href="/css/style.css?v=1763992124105">




    
        <link rel="stylesheet" href="/custom.css?v=1763992124105">
    
        <link rel="stylesheet" href="/themes/umaru/index.css?v=1763992124105">
    
        <link rel="stylesheet" href="/themes/asuka/index.css?v=1763992124105">
    



<script src="/lib/mdui_043tiny/mdui.js" async></script>
<script src="/lib/fancybox/fancybox.umd.js" async></script>
<script src="/lib/lax.min.js" async></script>


<script async src="/js/app.js?v=1763992124105"></script>

 

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-1Z7TFL96ZH"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-1Z7TFL96ZH');
</script>


<link rel="stylesheet"  href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
<!-- hexo injector head_end start -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-shiki-plugin@latest/lib/codeblock.css">
<style>:root{--hl-color:#e1e4e8;--hl-bg:#24292e;--hltools-bg:#1f2428;--hltools-color:#c5c5c5;--hlnumber-bg:#24292e;--hlnumber-color:#444d56;--hlscrollbar-bg:#32383e;--hlexpand-bg:linear-gradient(180deg,rgba(36,41,46,0.1),rgba(36,41,46,0.9))}</style><!-- hexo injector head_end end --><meta name="generator" content="Hexo 7.3.0"></head><body class="nexmoe mdui-drawer-body-left"><div id="nexmoe-background"><div class="nexmoe-bg" style="background-image: url(/images/background/xiaomai.jpg)"></div><div class="nexmoe-character"></div><div class="mdui-appbar mdui-shadow-0"><div class="mdui-toolbar"><a class="mdui-btn mdui-btn-icon mdui-ripple" mdui-drawer="{target: &#039;#drawer&#039;, swipe: true}" title="menu"><i class="mdui-icon nexmoefont icon-menu"></i></a><div class="mdui-toolbar-spacer"></div><a class="mdui-btn mdui-btn-icon" href="/" title="tangyuxian"><img src="/images/head/head.jpg" alt="tangyuxian"></a></div></div></div><div id="nexmoe-header"><div class="nexmoe-drawer mdui-drawer" id="drawer">
    <div class="nexmoe-avatar mdui-ripple">
        <a href="/" title="tangyuxian">
            <img src="/images/head/head.jpg" alt="tangyuxian" alt="tangyuxian">
        </a>
    </div>
    <div class="nexmoe-count">
        <div class="nexmoe-count-item"><span>文章</span>84 <div class="item-radius"></div><div class="item-radius item-right"></div> </div>
        <div class="nexmoe-count-item"><span>标签</span>38<div class="item-radius"></div><div class="item-radius item-right"></div></div>
        <div class="nexmoe-count-item"><span>分类</span>5<div class="item-radius"></div><div class="item-radius item-right"></div></div>
    </div>
    <div class="nexmoe-list mdui-list" mdui-collapse="{accordion: true}">
        
        <a class="nexmoe-list-item mdui-list-item mdui-ripple false" href="/" title="回到首页">
            <i class="mdui-list-item-icon nexmoefont icon-meishi"></i>
            <div class="mdui-list-item-content">
                回到首页
            </div>
        </a>
        
        <a class="nexmoe-list-item mdui-list-item mdui-ripple false" href="/archives.html" title="文章归档">
            <i class="mdui-list-item-icon nexmoefont icon-hanbao1"></i>
            <div class="mdui-list-item-content">
                文章归档
            </div>
        </a>
        
        <a class="nexmoe-list-item mdui-list-item mdui-ripple false" href="/about.html" title="关于糖糖">
            <i class="mdui-list-item-icon nexmoefont icon-jiubei1"></i>
            <div class="mdui-list-item-content">
                关于糖糖
            </div>
        </a>
        
        <a class="nexmoe-list-item mdui-list-item mdui-ripple false" href="/friend.html" title="我的朋友">
            <i class="mdui-list-item-icon nexmoefont icon-cola"></i>
            <div class="mdui-list-item-content">
                我的朋友
            </div>
        </a>
        
    </div>
    
    
        
        <div class="nexmoe-widget-wrap">
    <div class="nexmoe-widget nexmoe-search">
         
            <form id="search_form" action_e="https://cn.bing.com/search?q=site:tangyuxian.com" onsubmit="return search();">
                <label><input id="search_value" name="q" type="search" placeholder="搜索"></label>
            </form>
         
    </div>
</div>




    
        
        <div class="nexmoe-widget-wrap">
	<div class="nexmoe-widget nexmoe-social">
		<a
			class="mdui-ripple"
			href="http://wpa.qq.com/msgrd?v=3&uin=2120252100&site=qq&menu=yes"
			target="_blank"
			mdui-tooltip="{content: 'QQ'}"
			style="
				color: rgb(64, 196, 255);
				background-color: rgba(64, 196, 255, .1);
			"
		>
			<i
				class="nexmoefont icon-QQ"
			></i> </a
		><a
			class="mdui-ripple"
			href="mailto:tangyuxian@vip.qq.com"
			target="_blank"
			mdui-tooltip="{content: 'mail'}"
			style="
				color: rgb(249,8,8);
				background-color: rgba(249,8,8,.1);
			"
		>
			<i
				class="nexmoefont icon-mail-fill"
			></i> </a
		><a
			class="mdui-ripple"
			href="https://blog.csdn.net/qq_40621378?type=blog"
			target="_blank"
			mdui-tooltip="{content: 'CSDN'}"
			style="
				color: rgb(199,29,35);
				background-color: rgba(199,29,35,.1);
			"
		>
			<i
				class="nexmoefont icon-csdn"
			></i> </a
		><a
			class="mdui-ripple"
			href="https://www.cnblogs.com/lovetangyuxian/"
			target="_blank"
			mdui-tooltip="{content: '博客园'}"
			style="
				color: rgb(66, 214, 29);
				background-color: rgba(66, 214, 29, .1);
			"
		>
			<i
				class="nexmoefont icon-bokeyuan"
			></i> </a
		><a
			class="mdui-ripple"
			href="https://github.com/tangyuxian/"
			target="_blank"
			mdui-tooltip="{content: 'GitHub'}"
			style="
				color: rgb(25, 23, 23);
				background-color: rgba(25, 23, 23, .15);
			"
		>
			<i
				class="nexmoefont icon-github"
			></i> </a
		><a
			class="mdui-ripple"
			href="https://gitee.com/tangyuxian"
			target="_blank"
			mdui-tooltip="{content: 'gitee'}"
			style="
				color: rgb(255, 255, 255);
				background-color: rgb(199,29,35);
			"
		>
			<i
				class="nexmoefont icon-mayun"
			></i> </a
		>
	</div>
</div>

    
        
        
  <div class="nexmoe-widget-wrap">
    <h3 class="nexmoe-widget-title">文章分类</h3>
    <div class="nexmoe-widget">

      <ul class="category-list">

        


        

        

        <li class="category-list-item">
          <a class="category-list-link" href="/categories/其它/">其它</a>
          <span class="category-list-count">2</span>
        </li>

        

        <li class="category-list-item">
          <a class="category-list-link" href="/categories/前端/">前端</a>
          <span class="category-list-count">62</span>
        </li>

        

        <li class="category-list-item">
          <a class="category-list-link" href="/categories/后端/">后端</a>
          <span class="category-list-count">8</span>
        </li>

        

        <li class="category-list-item">
          <a class="category-list-link" href="/categories/开发工具/">开发工具</a>
          <span class="category-list-count">11</span>
        </li>

        

        <li class="category-list-item">
          <a class="category-list-link" href="/categories/服务器端/">服务器端</a>
          <span class="category-list-count">1</span>
        </li>

        
      </ul>

    </div>
  </div>


    
        
        
  <div class="nexmoe-widget-wrap">
    <div id="randomtagcloud" class="nexmoe-widget tagcloud nexmoe-rainbow">
      <a href="/tags/JavaScript/" style="font-size: 15.56px;">JavaScript</a> <a href="/tags/Jetbrains/" style="font-size: 10px;">Jetbrains</a> <a href="/tags/TypeScript/" style="font-size: 10px;">TypeScript</a> <a href="/tags/UI%E5%BA%93/" style="font-size: 13.33px;">UI库</a> <a href="/tags/centos/" style="font-size: 10px;">centos</a> <a href="/tags/css/" style="font-size: 11.11px;">css</a> <a href="/tags/docker/" style="font-size: 10px;">docker</a> <a href="/tags/echarts/" style="font-size: 10px;">echarts</a> <a href="/tags/elementPlus/" style="font-size: 13.33px;">elementPlus</a> <a href="/tags/es6/" style="font-size: 14.44px;">es6</a> <a href="/tags/git/" style="font-size: 13.33px;">git</a> <a href="/tags/github/" style="font-size: 10px;">github</a> <a href="/tags/html/" style="font-size: 10px;">html</a> <a href="/tags/http/" style="font-size: 13.33px;">http</a> <a href="/tags/java/" style="font-size: 11.11px;">java</a> <a href="/tags/markerdown/" style="font-size: 11.11px;">markerdown</a> <a href="/tags/nginx/" style="font-size: 10px;">nginx</a> <a href="/tags/node/" style="font-size: 13.33px;">node</a> <a href="/tags/vite/" style="font-size: 10px;">vite</a> <a href="/tags/vue/" style="font-size: 18.89px;">vue</a> <a href="/tags/webpack/" style="font-size: 10px;">webpack</a> <a href="/tags/xuex/" style="font-size: 10px;">xuex</a> <a href="/tags/%E4%BA%8B%E4%BB%B6%E6%B5%81/" style="font-size: 10px;">事件流</a> <a href="/tags/%E4%BA%92%E8%81%94%E7%BD%91/" style="font-size: 10px;">互联网</a> <a href="/tags/%E5%8A%A0%E5%AF%86/" style="font-size: 12.22px;">加密</a> <a href="/tags/%E5%8E%9F%E5%88%9B/" style="font-size: 20px;">原创</a> <a href="/tags/%E5%B7%A5%E5%85%B7/" style="font-size: 13.33px;">工具</a> <a href="/tags/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F/" style="font-size: 12.22px;">微信小程序</a> <a href="/tags/%E6%80%BB%E7%BB%93/" style="font-size: 13.33px;">总结</a> <a href="/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/" style="font-size: 10px;">数据结构</a> <a href="/tags/%E6%9C%8D%E5%8A%A1%E5%99%A8/" style="font-size: 10px;">服务器</a> <a href="/tags/%E6%B5%8F%E8%A7%88%E5%99%A8/" style="font-size: 17.78px;">浏览器</a> <a href="/tags/%E7%AE%97%E6%B3%95/" style="font-size: 14.44px;">算法</a> <a href="/tags/%E7%BC%96%E8%A7%A3%E7%A0%81/" style="font-size: 10px;">编解码</a> <a href="/tags/%E7%BE%8E%E5%8C%96/" style="font-size: 12.22px;">美化</a> <a href="/tags/%E8%A7%86%E9%A2%91/" style="font-size: 11.11px;">视频</a> <a href="/tags/%E8%AE%B0%E5%BD%95/" style="font-size: 11.11px;">记录</a> <a href="/tags/%E8%BD%AC%E8%BD%BD/" style="font-size: 16.67px;">转载</a>
    </div>
    
      <script>
        var maxTagcloud = parseInt(17);
        var tags_length = parseInt(38);
        var tags_arr = [];
        for(var i = 0; i < tags_length; i++){
          tags_arr.push(i);
        }
        tags_arr.sort(function (l, r) {
          return Math.random() > 0.5 ? -1 : 1;
        });
        tags_arr = tags_arr.slice(0, maxTagcloud < tags_length ? tags_length - maxTagcloud : 0);
        for(var tag_i = 0; tag_i < tags_arr.length; tag_i++){
          document.getElementById("randomtagcloud").children[tags_arr[tag_i]].style.display = 'none';
        }
      </script>
    
  </div>

    
        
        
        
  <div class="nexmoe-widget-wrap">
    <h3 class="nexmoe-widget-title">文章归档</h3>
    <div class="nexmoe-widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2025/">2025</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2023/">2023</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/">2022</a><span class="archive-list-count">23</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/">2021</a><span class="archive-list-count">54</span></li></ul>
    </div>
  </div>



    
        
        
  <div class="nexmoe-widget-wrap">
    <h3 class="nexmoe-widget-title">最新文章</h3>
    <div class="nexmoe-widget">
      <ul>
        
          <li>
            <a href="/2025/11/12/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/%E7%BE%8E%E5%8C%96/%E7%BE%8E%E5%8C%96-%E7%BD%91%E9%A1%B5%E4%B8%BB%E9%A2%98%E5%88%87%E6%8D%A2%E7%9A%84%E6%B8%90%E5%8F%98%E5%8A%A8%E7%94%BB/">美化-网页主题切换的渐变动画</a>
          </li>
        
          <li>
            <a href="/2025/09/29/%E5%89%8D%E7%AB%AF/css/css-%E8%A1%A8%E6%A0%BCtd%E4%B8%8B%E9%AB%98%E5%BA%A6%E4%B8%A2%E5%A4%B1%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95/">css-表格td下高度丢失解决办法</a>
          </li>
        
          <li>
            <a href="/2025/09/23/%E5%89%8D%E7%AB%AF/vue/vue-%E5%B0%81%E8%A3%85%E5%87%BD%E6%95%B0%E5%BC%8F%E8%A7%A6%E5%8F%91%E5%8F%B3%E9%94%AE%E8%8F%9C%E5%8D%95/">vue-封装函数式触发右键菜单组件</a>
          </li>
        
          <li>
            <a href="/2025/06/04/%E5%89%8D%E7%AB%AF/UI%E5%BA%93/UI%E5%BA%93-ElTooltip%E5%8F%AA%E5%9C%A8%E6%96%87%E5%AD%97%E8%B6%85%E5%87%BA%E8%8C%83%E5%9B%B4%E6%97%B6%E6%98%BE%E7%A4%BA%E7%9A%84%E8%A7%86%E7%BA%BF%E6%96%B9%E5%BC%8F/">UI库-ElTooltip只在文字超出范围时显示的视线方式</a>
          </li>
        
          <li>
            <a href="/2025/05/29/%E5%89%8D%E7%AB%AF/UI%E5%BA%93/UI%E5%BA%93-%E5%B0%81%E8%A3%85PageTable%E6%80%BB%E8%A7%88/">UI库-封装PageTable总览</a>
          </li>
        
      </ul>
    </div>
  </div>

    
        
        <div class="nexmoe-widget-wrap">
    <div class="nexmoe-widget nexmoe-link">
		<ul>
        
            <li>
                <a href="https://tangyuxian.com/" target="_blank" >
                    <img src="https://cdn.tangyuxian.com/PicGoImages/202304272004917.jpg" alt="糖糖第一可爱"></img>
                    <p style="color: var(--color-primary)">糖糖第一可爱</p>
                </a>
            </li>
        
		</ul>
    </div>
</div>
<style>
.nexmoe-widget-wrap .nexmoe-link ul li a {
    text-align : center;
}
.nexmoe-widget-wrap .nexmoe-link ul li a img {
    max-width : 100%;
}
.nexmoe-widget-wrap .nexmoe-link ul li a p {
    margin: 10px 0;
}
</style>

    
   
    <div class="nexmoe-copyright">
        &copy; 2025 tangyuxian
        Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
        & <a href="https://github.com/tangyuxian/hexo-theme-tangyuxian" target="_blank">Tangyuxian</a>
        <br><a target="_blank" href="https://beian.miit.gov.cn/">辽ICP备2021002341号</a>
<div style="font-size: 12px">
   <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
   本站总访问量  <a id="busuanzi_value_site_pv"></a> 次<br />
   本站访客数<a id="busuanzi_value_site_uv"></a>人次
</div>

    </div>
</div><!-- .nexmoe-drawer --></div><div id="nexmoe-content"><div class="nexmoe-primary"><div class="nexmoe-post">
  <article>
    
        <div class="nexmoe-post-cover">
            <img src="/images/post/git.jpg" alt="git-Git常用操作整理" loading="lazy">
            <h1>git-Git常用操作整理</h1>
        </div>
        
    
    <div class="nexmoe-post-meta">
    <div class="nexmoe-rainbow">
        <a class="nexmoefont icon-calendar-fill">2021年08月13日</a>
        
            <a class="nexmoefont icon-appstore-fill -link" href="/categories/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/">开发工具</a>
        
        
    </div>
    
    
    
    
    
</div>

    <p>Git常用操作整理…</p>
<span id="more"></span>

<h4 id="基础命令"><a href="#基础命令" class="headerlink" title="基础命令"></a>基础命令</h4><ul>
<li><h5 id="git-clone-克隆仓库代码："><a href="#git-clone-克隆仓库代码：" class="headerlink" title="git clone 克隆仓库代码："></a>git clone 克隆仓库代码：</h5>git clone <a target="_blank" rel="noopener" href="https://gitee.com/houpai/git-demo.git%EF%BC%88%E4%BB%93%E5%BA%93%E5%9C%B0%E5%9D%80%EF%BC%89">https://gitee.com/houpai/git-demo.git（仓库地址）</a></li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813100147449.png" alt="image-20210813100147449" data-caption="image-20210813100147449" loading="lazy"></p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813100121447.png" alt="image-20210813100121447" data-caption="image-20210813100121447" loading="lazy"></p>
<ul>
<li><h5 id="git-status查看本地工作区状态"><a href="#git-status查看本地工作区状态" class="headerlink" title="git status查看本地工作区状态"></a>git status查看本地工作区状态</h5><p>git status</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813102546895.png" alt="image-20210813102546895" data-caption="image-20210813102546895" loading="lazy"></p>
<p>如图上所示Untacked files提示该文件为添加到版本追踪里</p>
</li>
<li><h5 id="git-add-把修改-新增等提交暂存区"><a href="#git-add-把修改-新增等提交暂存区" class="headerlink" title="git add 把修改&#x2F;新增等提交暂存区"></a>git add 把修改&#x2F;新增等提交暂存区</h5><p> git add . ： 提交新文件(new)和被修改(modified)文件，不包括被删除(deleted)文件;–仅针对git版本为1.X的，目前2.X的含义是提交所有变化；</p>
</li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813104533648.png" alt="image-20210813104533648" data-caption="image-20210813104533648" loading="lazy"></p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813104738794.png" alt="image-20210813104738794" data-caption="image-20210813104738794" loading="lazy"></p>
<ul>
<li><h5 id="git-add-–u-提交被修改-modified-和被删除-deleted-文件，不包括新文件-new"><a href="#git-add-–u-提交被修改-modified-和被删除-deleted-文件，不包括新文件-new" class="headerlink" title="git add –u :  提交被修改(modified)和被删除(deleted)文件，不包括新文件(new);"></a>git add –u :  提交被修改(modified)和被删除(deleted)文件，不包括新文件(new);</h5><p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813105228259.png" alt="image-20210813105228259" data-caption="image-20210813105228259" loading="lazy"></p>
</li>
<li><h5 id="git-add-–A-提交所有变化"><a href="#git-add-–A-提交所有变化" class="headerlink" title="git add –A : 提交所有变化"></a>git add –A : 提交所有变化</h5></li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813105329430.png" alt="image-20210813105329430" data-caption="image-20210813105329430" loading="lazy"></p>
<blockquote>
<p><code>PS：在未commit命令之前，如果想撤销add , 可以用命令：git reset；</code></p>
</blockquote>
<ul>
<li><h5 id="git-commit-将暂存区的改动提交到本地仓库"><a href="#git-commit-将暂存区的改动提交到本地仓库" class="headerlink" title="git commit 将暂存区的改动提交到本地仓库"></a>git commit 将暂存区的改动提交到本地仓库</h5></li>
</ul>
<ol>
<li><p>每次使用git commit 命令我们都会在本地版本库生成一个40位的哈希值，这个哈希值也叫commit-id，commit-id在版本回退的时候是非常有用的，它相当于一个快照,可以在未来的任何时候通过与git reset的组合命令回到这里；</p>
</li>
<li><p>git commit –amend (原来提交基础上提交，不是新的提交)</p>
</li>
</ol>
<ul>
<li><h5 id="git-log-查看提交历史"><a href="#git-log-查看提交历史" class="headerlink" title="git log 查看提交历史"></a>git log 查看提交历史</h5><p> git log : 默认不用任何参数的话，git log 会按提交时间列出所有的更新，最近的更新排在最上面。每次更新都有一个 SHA-1 校验和、作者的名字和电子邮件地址、提交时间，最后缩进一个段落显示提交说明—commit –m 里的message。</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813115345755.png" alt="image-20210813115345755" data-caption="image-20210813115345755" loading="lazy"></p>
</li>
</ul>
<p>​	</p>
<p>​		git log –p: 选项展开显示每次提交的内容差异		</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813115526464.png" alt="image-20210813115526464" data-caption="image-20210813115526464" loading="lazy"></p>
<blockquote>
<p><code>PS:退出 :q</code></p>
</blockquote>
<p>​	git log -1 : 后面加数字，显示最近的几次提交</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813132434260.png" alt="image-20210813132434260" data-caption="image-20210813132434260" loading="lazy"></p>
<p>​	git log –p –word-diff : 单词层面上的对比</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813132632230.png" alt="image-20210813132632230" data-caption="image-20210813132632230" loading="lazy"></p>
<ul>
<li><h5 id="git-pull-将本地仓更新至远程仓的最新状态，获取代码并自动合并"><a href="#git-pull-将本地仓更新至远程仓的最新状态，获取代码并自动合并" class="headerlink" title="git pull : 将本地仓更新至远程仓的最新状态，获取代码并自动合并"></a>git pull : 将本地仓更新至远程仓的最新状态，获取代码并自动合并</h5><p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813132746452.png" alt="image-20210813132746452" data-caption="image-20210813132746452" loading="lazy"></p>
</li>
<li><h5 id="git-push-将本地分支的更新，推送到远程仓库"><a href="#git-push-将本地分支的更新，推送到远程仓库" class="headerlink" title="git push : 将本地分支的更新，推送到远程仓库"></a>git push : 将本地分支的更新，推送到远程仓库</h5><p> 如果当前分支和远程分支之前存在追踪关系，则git push origin 的含义是：将当前分支推送到origin主机的对应分支上；</p>
</li>
<li><h5 id="git-branch-–vv-查看本地当前分支与远程分支的追踪关系"><a href="#git-branch-–vv-查看本地当前分支与远程分支的追踪关系" class="headerlink" title="git branch –vv : 查看本地当前分支与远程分支的追踪关系"></a>git branch –vv : 查看本地当前分支与远程分支的追踪关系</h5><p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813133729555.png" alt="image-20210813133729555" data-caption="image-20210813133729555" loading="lazy"></p>
<blockquote>
<p><code>更改分支名称：git branch –m 改之前的分支名称  改之后的分支名称</code></p>
</blockquote>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813134333892.png" alt="image-20210813134333892" data-caption="image-20210813134333892" loading="lazy"></p>
</li>
<li><h5 id="git-checkout-切换分支"><a href="#git-checkout-切换分支" class="headerlink" title="git checkout : 切换分支"></a>git checkout : 切换分支</h5><p>  git checkout dev : 切换到dev 分支；</p>
<p>  git checkout –b dev :以当前分支为源创建分支dev；</p>
<blockquote>
<p><code>PS: git checkout –b dev是 git branch dev  ; git checkout dev 两条命令的简写</code></p>
</blockquote>
</li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813134601212.png" alt="image-20210813134601212" data-caption="image-20210813134601212" loading="lazy"></p>
<p>​		如果本地已经存在dev分支，则会提示；</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813134706819.png" alt="image-20210813134706819" data-caption="image-20210813134706819" loading="lazy">	</p>
<blockquote>
<p><code>PS：新创建的分支，是没有与远程关联的，需要先建立关联，把本地分支与远程建立追踪关系；git push --set-upstream origin dev</code></p>
</blockquote>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813135718369.png" alt="image-20210813135718369" data-caption="image-20210813135718369" loading="lazy"></p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813140211171.png" alt="image-20210813140211171" data-caption="image-20210813140211171" loading="lazy"></p>
<blockquote>
<p>​	<code>PS: git checkout --filename :该命令适用于：已经add后，后来又修改了文件，想要恢复之前add 的内容，则就可以把暂存区的内容替换到工作区了；或者没add 之前，我想把修改的内容恢复，也可以用git checkout filename;</code></p>
</blockquote>
<ul>
<li><h5 id="git-revert-撤销某次操作，并把此次撤销作为新的提交-请谨慎操作！）"><a href="#git-revert-撤销某次操作，并把此次撤销作为新的提交-请谨慎操作！）" class="headerlink" title="git revert :撤销某次操作，并把此次撤销作为新的提交( 请谨慎操作！）"></a>git revert :撤销某次操作，并把此次撤销作为新的提交( 请谨慎操作！）</h5><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813140902822.png" alt="image-20210813140902822" data-caption="image-20210813140902822" loading="lazy"></li>
</ul>
<p>​	git revert HEAD ：撤销前一次的commit ；</p>
<p>​	git  revert HEAD^ :撤销前前一次的commit;</p>
<p>​	git  revert commit-id :撤销指定版本的提交；</p>
<p>​	可以在命令中加上–no-edit参数。另一个重要的参数是-n或者–no-commit，应用这个参数会让revert 改动只限于程序员的本地仓库，而不自动进行commit</p>
<ul>
<li><h5 id="git-reset-用来将当前branch重置到另外一个commit的-请谨慎操作！）"><a href="#git-reset-用来将当前branch重置到另外一个commit的-请谨慎操作！）" class="headerlink" title="git reset : 用来将当前branch重置到另外一个commit的( 请谨慎操作！）"></a>git reset : 用来将当前branch重置到另外一个commit的( 请谨慎操作！）</h5><p>git reset HEAD : 重置当前分支到最近的一次提交；（HEAD这是当前分支版本顶端的别名，也就是在当前分支你最近的一个提交）</p>
<p>git reset HEAD~1 : 将HEAD从顶端的commit往下移动一个commit；从暂存区取出，替换到工作区；</p>
</li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813141313715.png" alt="image-20210813141313715" data-caption="image-20210813141313715" loading="lazy"></p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813141558893.png" alt="image-20210813141558893" data-caption="image-20210813141558893" loading="lazy"></p>
<blockquote>
<p><code>参数：--soft : 重置HEAD到另外一个commit，但也到此为止 , 所有变更都集中到暂存区，工作区；</code></p>
<p><code>--hard ：危险操作，所有变更全部丢失，不管本地仓，暂存区，工作区；</code></p>
<p><code>--mixed : 所有变更保存到工作区，本地仓，暂存区都丢失；默认参数；</code></p>
</blockquote>
<ul>
<li><h5 id="git-stash-储藏变更"><a href="#git-stash-储藏变更" class="headerlink" title="git stash : 储藏变更"></a>git stash : 储藏变更</h5><p>使用场景：当前工作区有变更，且作业没完成，但是需要切换到其他分支进行其他作业，需要干净的工作区间；</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813145829941.png" alt="image-20210813145829941" data-caption="image-20210813145829941" loading="lazy"></p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813150225555.png" alt="image-20210813150225555" data-caption="image-20210813150225555" loading="lazy"></p>
</li>
</ul>
<p>​	查看现有的所有储存：git stash list </p>
<p>​	<img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813150419586.png" alt="image-20210813150419586" data-caption="image-20210813150419586" loading="lazy"></p>
<p>其他分支作业完成后，返回之前分支，继续之前作业：git stash pop</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813150550178.png" alt="image-20210813150550178" data-caption="image-20210813150550178" loading="lazy"></p>
<blockquote>
<p><code>删除没用的储存：git stash drop stash@&#123;0&#125; / git stash clear</code></p>
</blockquote>
<ul>
<li><h5 id="git-merge-合并分支到当前分支"><a href="#git-merge-合并分支到当前分支" class="headerlink" title="git merge : 合并分支到当前分支"></a>git merge : 合并分支到当前分支</h5>首先切换到要合并的目标分支，比如把dev分支合并到master分支上，先切到master分支；</li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813151449597.png" alt="image-20210813151449597" data-caption="image-20210813151449597" loading="lazy"></p>
<p>​	git merge dev :把dev 分支合并到当前分支</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813151548854.png" alt="image-20210813151548854" data-caption="image-20210813151548854" loading="lazy"></p>
<p>​	 如果没有冲突的话，merge完成。有冲突的话，git会提示那个文件中有冲突，比如有如下冲突：</p>
<p>​	<img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813151658048.png" alt="image-20210813151658048" data-caption="image-20210813151658048" loading="lazy"></p>
<p>​	可以看到 &#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D; 隔开的上半部分，是 master 分支冲突的内容，下半部分是在 dev分支冲突的内容。</p>
<p>​	这个时候可以解决完冲突之后再进行相关操作：git add ; git commit 等等.</p>
<ul>
<li><h5 id="git-rebase-对于分支做‘变基’操作，可以理解为‘重新设置基线’"><a href="#git-rebase-对于分支做‘变基’操作，可以理解为‘重新设置基线’" class="headerlink" title="git rebase : 对于分支做‘变基’操作，可以理解为‘重新设置基线’"></a>git rebase : 对于分支做‘变基’操作，可以理解为‘重新设置基线’</h5><p>该命令适应于自己本地私有分支，远程分支慎用；</p>
<p>使用场景1：当你本地试图commit ,push 到一个remote时而因tracking branch过于陈旧而被拒绝的时候（原因是自从之前与orgin同步后，有其他人员提交了很多commit），如果强行push，会覆盖远程仓，把其他人员的commit给丢掉–谨慎，谨慎，谨慎；</p>
<p>回到rebase之前的状态：git rebase –abort </p>
<p>使用场景2：本地开发多次提交合并，便于管理跟踪，比如：dev 分支从master分支上创建，然后dev分支上自己提交了多个commit ,</p>
</li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155225050.png" alt="image-20210813155225050" data-caption="image-20210813155225050" loading="lazy"></p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155241666.png" alt="image-20210813155241666" data-caption="image-20210813155241666" loading="lazy"></p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155250923.png" alt="image-20210813155250923" data-caption="image-20210813155250923" loading="lazy"></p>
<p>​	我们设置第二个”pick 657a291 add 2.txt” 为” s 657a291 add 2.txt”这里的s就是squash命令的简写。</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155306599.png" alt="image-20210813155306599" data-caption="image-20210813155306599" loading="lazy"></p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155316585.png" alt="image-20210813155316585" data-caption="image-20210813155316585" loading="lazy"></p>
<p>​	删除之前的两条message(ESC dd)，设置一总的message 然后保存退出。(ESC wq)</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155333578.png" alt="image-20210813155333578" data-caption="image-20210813155333578" loading="lazy"></p>
<ul>
<li><h5 id="git-fsck-–lost-found-找回git-add-过，但是已经删除的文件内容"><a href="#git-fsck-–lost-found-找回git-add-过，但是已经删除的文件内容" class="headerlink" title="git fsck –lost-found : 找回git add 过，但是已经删除的文件内容"></a>git fsck –lost-found : 找回git add 过，但是已经删除的文件内容</h5></li>
<li><h5 id="git-branch-查看分支情况"><a href="#git-branch-查看分支情况" class="headerlink" title="git branch : 查看分支情况"></a>git branch : 查看分支情况</h5><p>查看项目的目前存在的分支情况，包括本地和远程 : git branch -a</p>
</li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155514556.png" alt="image-20210813155514556" data-caption="image-20210813155514556" loading="lazy"></p>
<p>删除本地分支 ：git branch –d dev (-d , 删除分支； -D ,强制删除分支)</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155822581.png" alt="image-20210813155822581" data-caption="image-20210813155822581" loading="lazy"></p>
<p>删除远程分支: git push origin :dev</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813155923526.png" alt="image-20210813155923526" data-caption="image-20210813155923526" loading="lazy"></p>
<h4 id="常用技巧"><a href="#常用技巧" class="headerlink" title="常用技巧"></a>常用技巧</h4><ul>
<li><h5 id="修改当前的追踪关系"><a href="#修改当前的追踪关系" class="headerlink" title="修改当前的追踪关系"></a>修改当前的追踪关系</h5><p>文件修改：本地打开.git à config 文件，别用记事本，修改[branch “master”]这一项是修改本地分支‘master’的远程追踪关系分支，直接修改merge &#x3D; refs&#x2F;heads&#x2F;master为merge &#x3D; refs&#x2F;heads&#x2F;dev；</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813160042246.png" alt="image-20210813160042246" data-caption="image-20210813160042246" loading="lazy"></p>
</li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813160058861.png" alt="image-20210813160058861" data-caption="image-20210813160058861" loading="lazy"></p>
<p>​	命令修改：git branch –set-upstream-to&#x3D;origin&#x2F;master</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813160112683.png" alt="image-20210813160112683" data-caption="image-20210813160112683" loading="lazy"></p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813160130746.png" alt="image-20210813160130746" data-caption="image-20210813160130746" loading="lazy"></p>
<ul>
<li><h5 id="查看远程版本库信息"><a href="#查看远程版本库信息" class="headerlink" title="查看远程版本库信息"></a>查看远程版本库信息</h5>git remote –v:</li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813160215210.png" alt="image-20210813160215210" data-caption="image-20210813160215210" loading="lazy"></p>
<ul>
<li><h5 id="更改远程仓库连接地址"><a href="#更改远程仓库连接地址" class="headerlink" title="更改远程仓库连接地址"></a>更改远程仓库连接地址</h5><p>ssh执行：git remote set-url origin <a href="mailto:&#103;&#x69;&#x74;&#x40;&#x67;&#105;&#116;&#101;&#101;&#x2e;&#99;&#111;&#x6d;">git@gitee.com</a>:houpai&#x2F;git-demo.git</p>
<p>http执行：git remote set-url origin  <a target="_blank" rel="noopener" href="https://github.com/NECKLI/git-test.git">https://github.com/NECKLI/git-test.git</a></p>
</li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813161758028.png" alt="image-20210813161758028" data-caption="image-20210813161758028" loading="lazy"></p>
<ul>
<li><h5 id="放弃本地修改，强制更新到本地"><a href="#放弃本地修改，强制更新到本地" class="headerlink" title="放弃本地修改，强制更新到本地"></a>放弃本地修改，强制更新到本地</h5><p>git fetch –all  &#x2F;&#x2F;只下载远程的库的内容，不做任何的合并</p>
<p>git reset –hard origin&#x2F;master  &#x2F;&#x2F;把HEAD指向刚下载的最新版本</p>
</li>
<li><h5 id="查看当前分支是基于哪个分支建立的"><a href="#查看当前分支是基于哪个分支建立的" class="headerlink" title="查看当前分支是基于哪个分支建立的"></a>查看当前分支是基于哪个分支建立的</h5><p>git reflog –-date&#x3D;local</p>
</li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813162919105.png" alt="image-20210813162919105" data-caption="image-20210813162919105" loading="lazy"></p>
<ul>
<li><h5 id="将某次提交合并到指定分支上"><a href="#将某次提交合并到指定分支上" class="headerlink" title="将某次提交合并到指定分支上"></a>将某次提交合并到指定分支上</h5><p>在修改分支上查看日志，找到对应的提交id</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813163337230.png" alt="image-20210813163337230" data-caption="image-20210813163337230" loading="lazy"></p>
<p>切换到指定分支: git checkout master1</p>
<p>再把指定的提交合并到当前分支：git cherry-pick commit-id</p>
</li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813163622576.png" alt="image-20210813163622576" data-caption="image-20210813163622576" loading="lazy"></p>
<ul>
<li><h5 id="版本回退"><a href="#版本回退" class="headerlink" title="版本回退"></a>版本回退</h5>先查看提交日志，找到要回退的版本，git log</li>
</ul>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813163821444.png" alt="image-20210813163821444" data-caption="image-20210813163821444" loading="lazy"></p>
<p>​	复制对应的commit id，<code>假如：e80d1d2e91b39a88908a3a0a31d15966d743c2df ；的提交； 本地版本回退：git reset --hard commit-id (如果确定不要该提交之后的提交，则可以用hard参数，如果要修改保留，则把hard参数去掉，重新提交)</code></p>
<p>本地之前的提交会全部丢失，使用的时候要谨慎；</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813165148007.png" alt="image-20210813165148007" data-caption="image-20210813165148007" loading="lazy"></p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813165633739.png" alt="image-20210813165633739" data-caption="image-20210813165633739" loading="lazy"></p>
<p> <code>	本地强制覆盖远程，使用的时候要谨慎，谨慎，谨慎 ,会影响其他人员使用，如果某人错误覆盖，则远程的其他提交没有了记录，要找回的话，可以找其他人员没有更新之前的代码，再同步到远程，如果其他人手里也没有了，则可以使用git fsck找回，操作会麻烦，--没具体实现过（http://blog.sina.com.cn/s/blog_66cd08930102x0ln.html）</code></p>
<ul>
<li><h5 id="本地创建远程分支"><a href="#本地创建远程分支" class="headerlink" title="本地创建远程分支"></a>本地创建远程分支</h5><p>例子：如现在有master , dev 分支，现在本地想以dev 分支为基分支创建新分支，并推送远程仓库, git checkout –b newDev</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813170306723.png" alt="image-20210813170306723" data-caption="image-20210813170306723" loading="lazy"></p>
<p>将本地newDev 分支作为远程newDev分支: git push origin newDev</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813170314683.png" alt="image-20210813170314683" data-caption="image-20210813170314683" loading="lazy"></p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813170329076.png" alt="image-20210813170329076" data-caption="image-20210813170329076" loading="lazy"></p>
<p>跟远程对应仓建立追踪关系： git branch –set-upstream-to&#x3D;origin&#x2F;newDev</p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813170336371.png" alt="image-20210813170336371" data-caption="image-20210813170336371" loading="lazy"></p>
<p><img onerror="imgOnError(this);" data-fancybox="gallery" src="https://cdn.jsdelivr.net/gh/houpai/hp-cdn@latest/picGo/image-20210813170345098.png" alt="image-20210813170345098" data-caption="image-20210813170345098" loading="lazy"></p>
<p>这个时候创建远程仓完成；在仓库里创建新分支比较简单，方便</p>
</li>
<li><h5 id="本地多次提交，push之前优化commits"><a href="#本地多次提交，push之前优化commits" class="headerlink" title="本地多次提交，push之前优化commits"></a>本地多次提交，push之前优化commits</h5></li>
</ul>
<p>​	git log 查看日志，找到要合并的commits</p>
<p>​	git rebase - i HEAD~2  ; &#x2F;&#x2F;优化最近的两次提交</p>
<p>​	对于 commit 合并可以使用 squash、fixup 指令，区别是 squash 会将该 commit 的注释添加到上一个 commit 注释中，fixup 是放弃当前 commit 的注释。</p>
<p>​	编辑后保存退出，git 会自动压缩提交历史，如果有冲突，记得解决冲突后，使用 git rebase –continue 重新回到当前的 git 压缩过程；</p>
<p>​	git push 推送到远程，再看git log ，提交日志就简洁多了。</p>
<ul>
<li><h5 id="本地全新项目，建本地仓，然后推送到远程"><a href="#本地全新项目，建本地仓，然后推送到远程" class="headerlink" title="本地全新项目，建本地仓，然后推送到远程"></a>本地全新项目，建本地仓，然后推送到远程</h5><p>远程仓库先建立一个仓库；</p>
<p>切换到项目目录下，然后初始化本地git仓，git init ；</p>
<p>将本地仓与远程仓进行关联，git remote add origin https:&#x2F;&#x2F;…..  .git</p>
<p>把项目添加到本地仓，git add *  git commit –m ‘注释’;</p>
<p>推送到远程仓，git push –u origin master ，（远程库是空的，我们第一次推送master分支时，加上了-u参数，Git不但会把本地的master分支内容推送的远程新的master分支，还会把本地的master分支和远程的master分支关联起来，在以后的推送或者拉取时就可以简化命令）。</p>
</li>
</ul>

    
  </article>

  
      
    <div class="nexmoe-post-copyright">
        <strong>本文作者：</strong>houpai<br>
        
            <strong>文章来源：</strong><a href="https://houpai.top/2021/08/13/Git%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C%E6%95%B4%E7%90%86/" title="https:&#x2F;&#x2F;houpai.top&#x2F;2021&#x2F;08&#x2F;13&#x2F;Git%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C%E6%95%B4%E7%90%86&#x2F;" target="_blank" rel="noopener">https:&#x2F;&#x2F;houpai.top&#x2F;2021&#x2F;08&#x2F;13&#x2F;Git%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C%E6%95%B4%E7%90%86&#x2F;</a><br>
        
        <strong>本文链接：</strong><a href="https://www.tangyuxian.com/2021/08/13/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/git/git-Git%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C%E6%95%B4%E7%90%86/" title="https:&#x2F;&#x2F;www.tangyuxian.com&#x2F;2021&#x2F;08&#x2F;13&#x2F;%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7&#x2F;git&#x2F;git-Git%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C%E6%95%B4%E7%90%86&#x2F;" target="_blank" rel="noopener">https:&#x2F;&#x2F;www.tangyuxian.com&#x2F;2021&#x2F;08&#x2F;13&#x2F;%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7&#x2F;git&#x2F;git-Git%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C%E6%95%B4%E7%90%86&#x2F;</a><br>

        
            <strong>版权声明：</strong>本文采用 <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/cn/deed.zh" target="_blank">CC BY-NC-SA 3.0 CN</a> 协议进行许可

        
    </div>


  
  
  <div class="nexmoe-post-meta nexmoe-rainbow">
   
    
        <a class="nexmoefont icon-tag-fill -none-link" href="/tags/git/" rel="tag">git</a> <a class="nexmoefont icon-tag-fill -none-link" href="/tags/%E8%BD%AC%E8%BD%BD/" rel="tag">转载</a>
    
</div>
  
  
    <script async src="/js/copy-codeblock.js?v=1763992123958"></script>
  

  
      <div class="nexmoe-post-footer">
          <div class="valine"></div>
<script src='https://lib.baomitu.com/valine/1.3.9/Valine.min.js'></script>
<script>
  new Valine({
      el: '.valine',
      appId: 'r5zxC0st0DDjPA9auXzMV7HY-gzGzoHsz',
      appKey: '3bqCsovpyfTPHUzTHovd3V3V'
  })
</script>

      </div>
  
</div></div><div class="nexmoe-post-right">    <div class="nexmoe-fixed">
        <div class="nexmoe-tool">

            

            
            
            <button class="mdui-fab catalog" style="overflow:unset;">
                <i class="nexmoefont icon-i-catalog"></i>
                <div class="nexmoe-toc">
                    <ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%9F%BA%E7%A1%80%E5%91%BD%E4%BB%A4"><span class="toc-number">1.</span> <span class="toc-text">基础命令</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#git-clone-%E5%85%8B%E9%9A%86%E4%BB%93%E5%BA%93%E4%BB%A3%E7%A0%81%EF%BC%9A"><span class="toc-number">1.1.</span> <span class="toc-text">git clone 克隆仓库代码：</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-status%E6%9F%A5%E7%9C%8B%E6%9C%AC%E5%9C%B0%E5%B7%A5%E4%BD%9C%E5%8C%BA%E7%8A%B6%E6%80%81"><span class="toc-number">1.2.</span> <span class="toc-text">git status查看本地工作区状态</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-add-%E6%8A%8A%E4%BF%AE%E6%94%B9-%E6%96%B0%E5%A2%9E%E7%AD%89%E6%8F%90%E4%BA%A4%E6%9A%82%E5%AD%98%E5%8C%BA"><span class="toc-number">1.3.</span> <span class="toc-text">git add 把修改&#x2F;新增等提交暂存区</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-add-%E2%80%93u-%E6%8F%90%E4%BA%A4%E8%A2%AB%E4%BF%AE%E6%94%B9-modified-%E5%92%8C%E8%A2%AB%E5%88%A0%E9%99%A4-deleted-%E6%96%87%E4%BB%B6%EF%BC%8C%E4%B8%8D%E5%8C%85%E6%8B%AC%E6%96%B0%E6%96%87%E4%BB%B6-new"><span class="toc-number">1.4.</span> <span class="toc-text">git add –u :  提交被修改(modified)和被删除(deleted)文件，不包括新文件(new);</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-add-%E2%80%93A-%E6%8F%90%E4%BA%A4%E6%89%80%E6%9C%89%E5%8F%98%E5%8C%96"><span class="toc-number">1.5.</span> <span class="toc-text">git add –A : 提交所有变化</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-commit-%E5%B0%86%E6%9A%82%E5%AD%98%E5%8C%BA%E7%9A%84%E6%94%B9%E5%8A%A8%E6%8F%90%E4%BA%A4%E5%88%B0%E6%9C%AC%E5%9C%B0%E4%BB%93%E5%BA%93"><span class="toc-number">1.6.</span> <span class="toc-text">git commit 将暂存区的改动提交到本地仓库</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-log-%E6%9F%A5%E7%9C%8B%E6%8F%90%E4%BA%A4%E5%8E%86%E5%8F%B2"><span class="toc-number">1.7.</span> <span class="toc-text">git log 查看提交历史</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-pull-%E5%B0%86%E6%9C%AC%E5%9C%B0%E4%BB%93%E6%9B%B4%E6%96%B0%E8%87%B3%E8%BF%9C%E7%A8%8B%E4%BB%93%E7%9A%84%E6%9C%80%E6%96%B0%E7%8A%B6%E6%80%81%EF%BC%8C%E8%8E%B7%E5%8F%96%E4%BB%A3%E7%A0%81%E5%B9%B6%E8%87%AA%E5%8A%A8%E5%90%88%E5%B9%B6"><span class="toc-number">1.8.</span> <span class="toc-text">git pull : 将本地仓更新至远程仓的最新状态，获取代码并自动合并</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-push-%E5%B0%86%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF%E7%9A%84%E6%9B%B4%E6%96%B0%EF%BC%8C%E6%8E%A8%E9%80%81%E5%88%B0%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93"><span class="toc-number">1.9.</span> <span class="toc-text">git push : 将本地分支的更新，推送到远程仓库</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-branch-%E2%80%93vv-%E6%9F%A5%E7%9C%8B%E6%9C%AC%E5%9C%B0%E5%BD%93%E5%89%8D%E5%88%86%E6%94%AF%E4%B8%8E%E8%BF%9C%E7%A8%8B%E5%88%86%E6%94%AF%E7%9A%84%E8%BF%BD%E8%B8%AA%E5%85%B3%E7%B3%BB"><span class="toc-number">1.10.</span> <span class="toc-text">git branch –vv : 查看本地当前分支与远程分支的追踪关系</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-checkout-%E5%88%87%E6%8D%A2%E5%88%86%E6%94%AF"><span class="toc-number">1.11.</span> <span class="toc-text">git checkout : 切换分支</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-revert-%E6%92%A4%E9%94%80%E6%9F%90%E6%AC%A1%E6%93%8D%E4%BD%9C%EF%BC%8C%E5%B9%B6%E6%8A%8A%E6%AD%A4%E6%AC%A1%E6%92%A4%E9%94%80%E4%BD%9C%E4%B8%BA%E6%96%B0%E7%9A%84%E6%8F%90%E4%BA%A4-%E8%AF%B7%E8%B0%A8%E6%85%8E%E6%93%8D%E4%BD%9C%EF%BC%81%EF%BC%89"><span class="toc-number">1.12.</span> <span class="toc-text">git revert :撤销某次操作，并把此次撤销作为新的提交( 请谨慎操作！）</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-reset-%E7%94%A8%E6%9D%A5%E5%B0%86%E5%BD%93%E5%89%8Dbranch%E9%87%8D%E7%BD%AE%E5%88%B0%E5%8F%A6%E5%A4%96%E4%B8%80%E4%B8%AAcommit%E7%9A%84-%E8%AF%B7%E8%B0%A8%E6%85%8E%E6%93%8D%E4%BD%9C%EF%BC%81%EF%BC%89"><span class="toc-number">1.13.</span> <span class="toc-text">git reset : 用来将当前branch重置到另外一个commit的( 请谨慎操作！）</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-stash-%E5%82%A8%E8%97%8F%E5%8F%98%E6%9B%B4"><span class="toc-number">1.14.</span> <span class="toc-text">git stash : 储藏变更</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-merge-%E5%90%88%E5%B9%B6%E5%88%86%E6%94%AF%E5%88%B0%E5%BD%93%E5%89%8D%E5%88%86%E6%94%AF"><span class="toc-number">1.15.</span> <span class="toc-text">git merge : 合并分支到当前分支</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-rebase-%E5%AF%B9%E4%BA%8E%E5%88%86%E6%94%AF%E5%81%9A%E2%80%98%E5%8F%98%E5%9F%BA%E2%80%99%E6%93%8D%E4%BD%9C%EF%BC%8C%E5%8F%AF%E4%BB%A5%E7%90%86%E8%A7%A3%E4%B8%BA%E2%80%98%E9%87%8D%E6%96%B0%E8%AE%BE%E7%BD%AE%E5%9F%BA%E7%BA%BF%E2%80%99"><span class="toc-number">1.16.</span> <span class="toc-text">git rebase : 对于分支做‘变基’操作，可以理解为‘重新设置基线’</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-fsck-%E2%80%93lost-found-%E6%89%BE%E5%9B%9Egit-add-%E8%BF%87%EF%BC%8C%E4%BD%86%E6%98%AF%E5%B7%B2%E7%BB%8F%E5%88%A0%E9%99%A4%E7%9A%84%E6%96%87%E4%BB%B6%E5%86%85%E5%AE%B9"><span class="toc-number">1.17.</span> <span class="toc-text">git fsck –lost-found : 找回git add 过，但是已经删除的文件内容</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#git-branch-%E6%9F%A5%E7%9C%8B%E5%88%86%E6%94%AF%E6%83%85%E5%86%B5"><span class="toc-number">1.18.</span> <span class="toc-text">git branch : 查看分支情况</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%B8%B8%E7%94%A8%E6%8A%80%E5%B7%A7"><span class="toc-number">2.</span> <span class="toc-text">常用技巧</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E5%BD%93%E5%89%8D%E7%9A%84%E8%BF%BD%E8%B8%AA%E5%85%B3%E7%B3%BB"><span class="toc-number">2.1.</span> <span class="toc-text">修改当前的追踪关系</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E8%BF%9C%E7%A8%8B%E7%89%88%E6%9C%AC%E5%BA%93%E4%BF%A1%E6%81%AF"><span class="toc-number">2.2.</span> <span class="toc-text">查看远程版本库信息</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%9B%B4%E6%94%B9%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E8%BF%9E%E6%8E%A5%E5%9C%B0%E5%9D%80"><span class="toc-number">2.3.</span> <span class="toc-text">更改远程仓库连接地址</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%94%BE%E5%BC%83%E6%9C%AC%E5%9C%B0%E4%BF%AE%E6%94%B9%EF%BC%8C%E5%BC%BA%E5%88%B6%E6%9B%B4%E6%96%B0%E5%88%B0%E6%9C%AC%E5%9C%B0"><span class="toc-number">2.4.</span> <span class="toc-text">放弃本地修改，强制更新到本地</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E5%BD%93%E5%89%8D%E5%88%86%E6%94%AF%E6%98%AF%E5%9F%BA%E4%BA%8E%E5%93%AA%E4%B8%AA%E5%88%86%E6%94%AF%E5%BB%BA%E7%AB%8B%E7%9A%84"><span class="toc-number">2.5.</span> <span class="toc-text">查看当前分支是基于哪个分支建立的</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E5%B0%86%E6%9F%90%E6%AC%A1%E6%8F%90%E4%BA%A4%E5%90%88%E5%B9%B6%E5%88%B0%E6%8C%87%E5%AE%9A%E5%88%86%E6%94%AF%E4%B8%8A"><span class="toc-number">2.6.</span> <span class="toc-text">将某次提交合并到指定分支上</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E7%89%88%E6%9C%AC%E5%9B%9E%E9%80%80"><span class="toc-number">2.7.</span> <span class="toc-text">版本回退</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%9C%AC%E5%9C%B0%E5%88%9B%E5%BB%BA%E8%BF%9C%E7%A8%8B%E5%88%86%E6%94%AF"><span class="toc-number">2.8.</span> <span class="toc-text">本地创建远程分支</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%9C%AC%E5%9C%B0%E5%A4%9A%E6%AC%A1%E6%8F%90%E4%BA%A4%EF%BC%8Cpush%E4%B9%8B%E5%89%8D%E4%BC%98%E5%8C%96commits"><span class="toc-number">2.9.</span> <span class="toc-text">本地多次提交，push之前优化commits</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%9C%AC%E5%9C%B0%E5%85%A8%E6%96%B0%E9%A1%B9%E7%9B%AE%EF%BC%8C%E5%BB%BA%E6%9C%AC%E5%9C%B0%E4%BB%93%EF%BC%8C%E7%84%B6%E5%90%8E%E6%8E%A8%E9%80%81%E5%88%B0%E8%BF%9C%E7%A8%8B"><span class="toc-number">2.10.</span> <span class="toc-text">本地全新项目，建本地仓，然后推送到远程</span></a></li></ol></li></ol>
                </div>
            </button>
            

            

            <a href="#nexmoe-content" class="backtop toc-link" aria-label="Back To Top" title="top"><button class="mdui-fab mdui-ripple"><i class="nexmoefont icon-caret-top"></i></button></a>
        </div>
    </div>
</div></div><div id="nexmoe-pendant"><div class="nexmoe-drawer mdui-drawer nexmoe-pd" id="drawer">
    
        
            <div class="nexmoe-pd-item">
                <div class="clock">
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="memory"></div>
        <div class="needle" id="hours"></div>
        <div class="needle" id="minutes"></div>
        <div class="needle" id="seconds"></div>
        <div class="clock_logo">

        </div>

    </div>
<script>
        // ----- Variable declaration

        var data = {
                dt: new Date(),
                hours: {
                        el: document.querySelector('#hours'),
                        val: 0 },

                minutes: {
                        el: document.querySelector('#minutes'),
                        val: 0 },

                seconds: {
                        el: document.querySelector('#seconds'),
                        val: 0 },

                renderTime: 1000 };


        // ----- Clock rendering logic

        updateTime = () => {
                let hour = data.dt.getHours();
                let minute = data.dt.getMinutes();
                let second = data.dt.getSeconds();

                data.hours.el.classList.add('moving');
                data.minutes.el.classList.add('moving');
                data.seconds.el.classList.add('moving');

                data.hours.val = hour == 0 && data.hours.val == 59 * 6 * 5 ? 360 : hour * 6 * 5;
                data.minutes.val = minute == 0 && data.minutes.val == 59 * 6 ? 360 : minute * 6;
                data.seconds.val = second == 0 && data.seconds.val == 59 * 6 ? 360 : second * 6;

                data.hours.el.style.transform = `translate(-50%, -75%) rotate(${data.hours.val}deg)`;
                data.minutes.el.style.transform = `translate(-50%, -75%) rotate(${data.minutes.val}deg)`;
                data.seconds.el.style.transform = `translate(-50%, -75%) rotate(${data.seconds.val}deg)`;

                data.dt.setSeconds(second + 1);
        };

        // ----- Clock execution

        setInterval(() => {
                updateTime();
        }, data.renderTime);

        updateTime();

        // ----- Events area

        data.seconds.el.addEventListener('transitionend', () => {
                data.hours.el.classList.remove('moving');
                data.minutes.el.classList.remove('moving');
                data.seconds.el.classList.remove('moving');

                // if (data.hours.val == 360) {
                //   data.hours.el.style.transform = 'translate(-50%, -75%) rotate(0deg)';
                // }

                if (data.minutes.val == 360) {
                        data.minutes.el.style.transform = 'translate(-50%, -75%) rotate(0deg)';
                }

                if (data.seconds.val == 360) {
                        data.seconds.el.style.transform = 'translate(-50%, -75%) rotate(0deg)';
                }
        });

</script>
<style>
    .clock {
        background-color: #ffffff;
        width: 70vw;
        height: 70vw;
        max-width: 70vh;
        max-height: 70vh;
        border: solid 2.8vw var(--color-primary);
        position: relative;
        overflow: hidden;
        border-radius: 50%;
        box-sizing: border-box;
        box-shadow: 0 1.4vw 2.8vw var(--color2);
        zoom:0.2
    }

    .memory {
        position: absolute;
        top: 50%;
        left: 50%;
        transform-origin: center;
    }

    .memory:nth-child(1) {
        background-color: var(--color-primary);
        width: 2%;
        height: 8%;
        transform: translate(-50%, -50%) rotate(0deg) translateY(-520%);
    }

    .memory:nth-child(2) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(6deg) translateY(-1461%);
    }

    .memory:nth-child(3) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(12deg) translateY(-1461%);
    }

    .memory:nth-child(4) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(18deg) translateY(-1461%);
    }

    .memory:nth-child(5) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(24deg) translateY(-1461%);
    }

    .memory:nth-child(6) {
        background-color: var(--color-primary);
        width: 2%;
        height: 8%;
        transform: translate(-50%, -50%) rotate(30deg) translateY(-520%);
    }

    .memory:nth-child(7) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(36deg) translateY(-1461%);
    }

    .memory:nth-child(8) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(42deg) translateY(-1461%);
    }

    .memory:nth-child(9) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(48deg) translateY(-1461%);
    }

    .memory:nth-child(10) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(54deg) translateY(-1461%);
    }

    .memory:nth-child(11) {
        background-color: var(--color-primary);
        width: 2%;
        height: 8%;
        transform: translate(-50%, -50%) rotate(60deg) translateY(-520%);
    }

    .memory:nth-child(12) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(66deg) translateY(-1461%);
    }

    .memory:nth-child(13) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(72deg) translateY(-1461%);
    }

    .memory:nth-child(14) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(78deg) translateY(-1461%);
    }

    .memory:nth-child(15) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(84deg) translateY(-1461%);
    }

    .memory:nth-child(16) {
        background-color: var(--color-primary);
        width: 2%;
        height: 8%;
        transform: translate(-50%, -50%) rotate(90deg) translateY(-520%);
    }

    .memory:nth-child(17) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(96deg) translateY(-1461%);
    }

    .memory:nth-child(18) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(102deg) translateY(-1461%);
    }

    .memory:nth-child(19) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(108deg) translateY(-1461%);
    }

    .memory:nth-child(20) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(114deg) translateY(-1461%);
    }

    .memory:nth-child(21) {
        background-color: var(--color-primary);
        width: 2%;
        height: 8%;
        transform: translate(-50%, -50%) rotate(120deg) translateY(-520%);
    }

    .memory:nth-child(22) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(126deg) translateY(-1461%);
    }

    .memory:nth-child(23) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(132deg) translateY(-1461%);
    }

    .memory:nth-child(24) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(138deg) translateY(-1461%);
    }

    .memory:nth-child(25) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(144deg) translateY(-1461%);
    }

    .memory:nth-child(26) {
        background-color: var(--color-primary);
        width: 2%;
        height: 8%;
        transform: translate(-50%, -50%) rotate(150deg) translateY(-520%);
    }

    .memory:nth-child(27) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(156deg) translateY(-1461%);
    }

    .memory:nth-child(28) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(162deg) translateY(-1461%);
    }

    .memory:nth-child(29) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(168deg) translateY(-1461%);
    }

    .memory:nth-child(30) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(174deg) translateY(-1461%);
    }

    .memory:nth-child(31) {
        background-color: var(--color-primary);
        width: 2%;
        height: 8%;
        transform: translate(-50%, -50%) rotate(180deg) translateY(-520%);
    }

    .memory:nth-child(32) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(186deg) translateY(-1461%);
    }

    .memory:nth-child(33) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(192deg) translateY(-1461%);
    }

    .memory:nth-child(34) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(198deg) translateY(-1461%);
    }

    .memory:nth-child(35) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(204deg) translateY(-1461%);
    }

    .memory:nth-child(36) {
        background-color: var(--color-primary);
        width: 2%;
        height: 8%;
        transform: translate(-50%, -50%) rotate(210deg) translateY(-520%);
    }

    .memory:nth-child(37) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(216deg) translateY(-1461%);
    }

    .memory:nth-child(38) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(222deg) translateY(-1461%);
    }

    .memory:nth-child(39) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(228deg) translateY(-1461%);
    }

    .memory:nth-child(40) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(234deg) translateY(-1461%);
    }

    .memory:nth-child(41) {
        background-color: var(--color-primary);
        width: 2%;
        height: 8%;
        transform: translate(-50%, -50%) rotate(240deg) translateY(-520%);
    }

    .memory:nth-child(42) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(246deg) translateY(-1461%);
    }

    .memory:nth-child(43) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(252deg) translateY(-1461%);
    }

    .memory:nth-child(44) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(258deg) translateY(-1461%);
    }

    .memory:nth-child(45) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(264deg) translateY(-1461%);
    }

    .memory:nth-child(46) {
        background-color: var(--color-primary);
        width: 2%;
        height: 8%;
        transform: translate(-50%, -50%) rotate(270deg) translateY(-520%);
    }

    .memory:nth-child(47) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(276deg) translateY(-1461%);
    }

    .memory:nth-child(48) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(282deg) translateY(-1461%);
    }

    .memory:nth-child(49) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(288deg) translateY(-1461%);
    }

    .memory:nth-child(50) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(294deg) translateY(-1461%);
    }

    .memory:nth-child(51) {
        background-color: var(--color-primary);
        width: 2%;
        height: 8%;
        transform: translate(-50%, -50%) rotate(300deg) translateY(-520%);
    }

    .memory:nth-child(52) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(306deg) translateY(-1461%);
    }

    .memory:nth-child(53) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(312deg) translateY(-1461%);
    }

    .memory:nth-child(54) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(318deg) translateY(-1461%);
    }

    .memory:nth-child(55) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(324deg) translateY(-1461%);
    }

    .memory:nth-child(56) {
        background-color: var(--color-primary);
        width: 2%;
        height: 8%;
        transform: translate(-50%, -50%) rotate(330deg) translateY(-520%);
    }

    .memory:nth-child(57) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(336deg) translateY(-1461%);
    }

    .memory:nth-child(58) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(342deg) translateY(-1461%);
    }

    .memory:nth-child(59) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(348deg) translateY(-1461%);
    }

    .memory:nth-child(60) {
        background-color: #949494;
        width: 1%;
        height: 3%;
        transform: translate(-50%, -50%) rotate(354deg) translateY(-1461%);
    }

    .needle {
        position: absolute;
        top: 50%;
        left: 50%;
        transform-origin: center;
    }

    .needle#hours {
        background-color: #1f1f1f;
        width: 4%;
        height: 30%;
        transform-origin: center 75%;
        transform: translate(-50%, -75%);
    }

    .needle#hours.moving {
        transition: transform 150ms ease-out;
    }

    .needle#hours:after {
        content: '';
        background-color: #1f1f1f;
        width: 4vw;
        height: 4vw;
        max-width: 4vh;
        max-height: 4vh;
        display: block;
        position: absolute;
        top: 75%;
        left: 50%;
        box-sizing: border-box;
        border-radius: 50%;
        transform: translate(-50%, -50%);
    }

    .needle#minutes {
        background-color: #1f1f1f;
        width: 2%;
        height: 45%;
        transform-origin: center 75%;
        transform: translate(-50%, -75%);
    }

    .needle#minutes.moving {
        transition: transform 150ms ease-out;
    }

    .needle#minutes:after {
        content: '';
        background-color: #1f1f1f;
        width: 4vw;
        height: 4vw;
        max-width: 4vh;
        max-height: 4vh;
        display: block;
        position: absolute;
        top: 75%;
        left: 50%;
        box-sizing: border-box;
        border-radius: 50%;
        transform: translate(-50%, -50%);
    }

    .needle#seconds {
        background-color: #cb2f2f;
        width: 1%;
        height: 50%;
        transform-origin: center 75%;
        transform: translate(-50%, -75%);
    }

    .needle#seconds.moving {
        transition: transform 150ms ease-out;
    }

    .needle#seconds:after {
        content: '';
        background-color: #cb2f2f;
        width: 2.5vw;
        height: 2.5vw;
        max-width: 2.5vh;
        max-height: 2.5vh;
        display: block;
        position: absolute;
        top: 75%;
        left: 50%;
        box-sizing: border-box;
        border-radius: 50%;
        transform: translate(-50%, -50%);
    }
    .clock_logo{
        width: 10vw;
        height: 10vw;
        max-width: 10vh;
        max-height: 10vh;
        position: absolute;
        top: 50%;
        left: 50%;
        box-sizing: border-box;
        border-radius: 50%;
        transform: translate(-50%, -50%);
        background-size: 100% 100%;
        background-repeat: no-repeat;
    }
    .clock_logo{
            width: 10vw;
            height: 10vw;
            max-width: 10vh;
            max-height: 10vh;
            position: absolute;
            top: 50%;
            left: 50%;
            box-sizing: border-box;
            border-radius: 50%;
            transform: translate(-50%, -50%);
            background-image: var(--clock-logo);
            background-size: 100% 100%;
            background-repeat: no-repeat;
    }
    @media (min-width: 100vh) {
        .clock {
            border: solid 2.8vh var(--color-primary);
            box-shadow: 0 1.4vh 2.8vh var(--color2);
        }
    }

</style>





            </div>
        
            <div class="nexmoe-pd-item">
                <div class="qweather" >
    <div id="he-plugin-standard">
        <iframe allowtransparency="true" frameborder="0" width="304" height="96" scrolling="no" src="//tianqi.2345.com/plugin/widget/index.htm?s=2&z=1&t=0&v=0&d=2&bd=0&k=000000&f=ff8040&ltf=009944&htf=cc0000&q=1&e=1&a=1&c=54511&w=300&h=96&align=center"></iframe>
    </div>
    <div class="qweather-logo">

    </div>
</div>
<style>
    .qweather{
        position: relative;
        padding-right: 5px;
    }
    .qweather #he-plugin-standard {
        border: 2px solid var(--color-primary);
        box-shadow: 0 1px 0 0 var(--color-primary), 0 1px 2px 0 var(--color-primary);
        border-radius: 8px;
        width: 300px;
        overflow: hidden;
    }
    .qweather-logo{
        position: absolute;
        right: 0;
        top: -15px;
        width: 40px;
        height: 40px;
        background-image: var(--qweather-logo);
        background-size: 100% 100%;
        background-repeat: no-repeat;
    }
</style>

            </div>
        
    
</div>
<style>
    .nexmoe-pd {
        left: auto;
        top: 40px;
        right: 0;
    }
    .nexmoe-pd-item{
       display: flex;
        justify-content: center;
        margin-bottom: 30px;
    }
    #nexmoe-pendant .mdui-drawer{
        width: 305px;
    }
    @media screen and (max-width: 1600px) {
        #nexmoe-pendant {
            display: none
        }
    }
</style>
</div><div id="nexmoe-footer"><!--!--></div><div id="nexmoe-search-space"><div class="search-container"><div class="search-header"><div class="search-input-container"><input class="search-input" type="text" placeholder="搜索" onInput="sinput();"></div><a class="search-close" onclick="sclose();">×</a></div><div class="search-body"></div></div></div><div></div><!-- hexo injector body_end start -->
<script src="https://cdn.jsdelivr.net/npm/hexo-shiki-plugin@latest/lib/codeblock.js"></script>

  <script>
  const CODE_CONFIG = {
    beautify: true,
    highlightCopy: true,
    highlightLang: true,
    highlightHeightLimit: null,
    isHighlightShrink: false,
    copy: {
      success: 'Copy Success',
      error: 'Copy Error',
      noSupport: 'Browser Not Support',
    }
  };
  console.log(
    `%c hexo-shiki-plugin %c v1.0.27 %c https://github.com/nova1751/hexo-shiki-plugin`,
    "color: #fff; background: #5f5f5f",
    "color: #fff; background: #80c8f8",
    ""
  );
  </script>
  <!-- hexo injector body_end end --><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"model":{"jsonPath":"/live2dw/assets/xiaomai.model.json"},"display":{"position":"left","width":200,"height":500},"mobile":{"show":false},"react":{"opacity":0.9},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body></html>